package com.codeoss.module.ir.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.codeoss.framework.context.UserContext;
import com.codeoss.framework.service.impl.BaseTreeService;
import com.codeoss.module.ir.dao.IrMobileMenuMapper;
import com.codeoss.module.ir.model.IrMobileMenu;
import com.codeoss.module.ir.service.IIrMobileMenuService;

@Service
public class IrMobileMenuService extends BaseTreeService<IrMobileMenuMapper, IrMobileMenu>
		implements IIrMobileMenuService {

	@Override
	public List<Map<String, Object>> getCanAccessMobileMenuList() {
		// TODO Auto-generated method stub
		UserContext userContext=UserContext.getCurrentUserContext();
		QueryWrapper<IrMobileMenu> query=new QueryWrapper<IrMobileMenu>();
		query.eq("menu_type", "folder");
		query.or();
		query.inSql("id", "(select ir_mobile_menu_id from res_rel_role_mobile_menu where res_role_id in(select res_role_id from res_rel_user_role where res_user_id="+userContext.getResUserId()+"))");
		query.last("or('"+userContext.getUsername()+"'='admin') order by seq_no asc");
		return listMaps(query);
	}
}